class GameStats:
    def __init__(self, ai_game):
        self.settings = ai_game.settings
        self.reset_stats()
        self.game_active = False
        try:
            with open(mode="r", file="high_score.txt") as file:
                try:
                    self.high_score = int(file.read().rstrip())
                except ValueError:
                    self.high_score = 0
        except FileNotFoundError:
            ai_game._create_log_file()
    def reset_stats(self):
        self.ships_left = self.settings.ship_limit
        self.score = 0
        self.level = 1